package br.com.exemplo.controller;

import java.util.*;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.exemplo.model.CervejaExpert;

@WebServlet("/PrimeiroServlet")
public class SelecaoCerveja extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public SelecaoCerveja() {
		super();
		// TODO Auto-generated constructor stub
	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		response.setContentType("text/html");
		PrintWriter out = response.getWriter();

		String c = request.getParameter("cor");
		out.println("<h1>Cervejas sugeridas</h1><br/>");

		CervejaExpert ce = new CervejaExpert();
		List<String> resultado = ce.getMarcas(c);
		Iterator it = resultado.iterator();

		while (it.hasNext()) {
			out.println("<br/>Experimente " + it.next());
		}
	}

}
